# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=sonar-scanner
pkgver=5.0.1.3006
pkgrel=0
pkgdesc="Scanner CLI for SonarQube and SonarCloud"
url="https://github.com/SonarSource/sonar-scanner-cli"
arch="noarch !x86 !armhf !armv7 !riscv64 !ppc64le" # blocked by openjdk17
license="LGPL-3.0-or-later"
depends="openjdk17-jre-headless"
makedepends="maven openjdk17-jdk"
source="https://github.com/SonarSource/sonar-scanner-cli/archive/$pkgver/sonar-scanner-$pkgver.tar.gz
	fix-reflection.patch
	"
builddir="$srcdir/sonar-scanner-cli-$pkgver"

prepare() {
	default_prepare
	sed -i "s/<version>.*-SNAPSHOT/<version>$pkgver/" pom.xml
}

build() {
	mvn clean package
}

check() {
	mvn test
}

package() {
	local dest=/usr/share/sonar-scanner

	mkdir -p "$pkgdir"/$dest
	unzip target/sonar-scanner-$pkgver.zip
	mv sonar-scanner-$pkgver/* "$pkgdir"/$dest/

	mkdir -p "$pkgdir"/usr/bin
	ln -svf $dest/bin/sonar-scanner "$pkgdir"/usr/bin
}

sha512sums="
a589a343b2c48b7b44086c47d28be6282d1888ef4afbc500994d64c9b1ce14dc7d7ec83515ae288ad14f263cd130dc6eab6df91095bd7f7ed2a72a6cdab399ff  sonar-scanner-5.0.1.3006.tar.gz
defc90c2cecef172e94c962b4058daadcf2411e4a6b98ca5868abb85f19359cc515df79d931335f79e5c0ba8bab1da833654a11553056fcbfba78c7625b1f425  fix-reflection.patch
"
